/***************************************************************************
 * Open Object Oriented ANSI C                                             *
 ***************************************************************************
 * Code given under the terms of GNU General Public Licence (GPLv3)        *
 * and without any waranties of any kind including but not limitative to   *
 * waranties on merchandability or any particular applications fitness.    *
 * For more information on GNU/GPL go on :                                 *
 * "http://www.gnu.org/copyleft/gpl.html"                                  *
 *                                                                         *
 * You are allowed to use it for any purposes in the terms of GNU/GPLv3    *
 * (or more).                                                              *
 * This text MUST stay in state on copyed sources (or sources using it)    *
 * and must not be altered.                                                *
 * You are allowed to add your name at the end of the Copylefs list.       *
 ***************************************************************************
 * Copylefts List :                                                        *
 ***************************************************************************
 * 2010-04-16 Patrick PIGNOL <pignol_patrick@hotmail.com> (Original)       *
 * (Type your name here if needed)                                         *
 ***************************************************************************/
#include <stdarg.h>
#include <signal.h>
#include "EventArgs.h"
#include "Mem.h"
#include "Class.h"
#include "Exception.h"
#include "ExceptionManager.h"

static EventArgsVirtualTable* EventArgsVirtualTableInstance = 0;

EventArgs* EventArgsNew(unsigned long pArgsCount, va_list* pParameters)
{
    EventArgs* this;
    this = (EventArgs*) malloc(sizeof(EventArgs));
    if(!this)
    {
        raise(SIGABRT);
    }
    this->VirtualTable = EventArgsInitialize(this, pArgsCount, pParameters);
    this->Constructor = EventArgsConstructor;
    this->Destructor = EventArgsDestructor;
    this->Clone = EventArgsClone;
    return this;
}

EventArgsVirtualTable* EventArgsInitialize(EventArgs* this, unsigned long pArgsCount, va_list* pParameters)
{
    if(!EventArgsVirtualTableInstance)
    {
        EventArgsVirtualTableInstance = (EventArgsVirtualTable*) malloc(sizeof(EventArgsVirtualTable));
        if(!EventArgsVirtualTableInstance)
        {
            raise(SIGABRT);
        }

        EventArgsVirtualTableInstance->TypeID = EVENTARGS_TYPEID;

        EventArgsVirtualTableInstance->Interface = (EventArgsInterface*)malloc(sizeof(EventArgsInterface));
        if(!EventArgsVirtualTableInstance->Interface)
        {
            raise(SIGABRT);
        }
        EventArgsVirtualTableInstance->Interface->Constructor = EventArgsConstructor;
        EventArgsVirtualTableInstance->Interface->Destructor = EventArgsDestructor;
        EventArgsVirtualTableInstance->Interface->Clone = EventArgsClone;

        EventArgsVirtualTableInstance->AncestorTable = ClassInitialize((Class*)this, pArgsCount, pParameters);

        EventArgsVirtualTableInstance->ReferenceCount = 0;

        EventArgsVirtualTableInstance->new = EventArgsNew;
        EventArgsVirtualTableInstance->Initialize = EventArgsInitialize;
        EventArgsVirtualTableInstance->Garbage = (void (*)(EventArgs*))EventArgsVirtualTableInstance->AncestorTable->Garbage;
        EventArgsVirtualTableInstance->TypeOf = (unsigned long int (*)(EventArgs*))EventArgsVirtualTableInstance->AncestorTable->TypeOf;
        EventArgsVirtualTableInstance->IsSameTypeThanTypeID = (bool (*)(EventArgs*, unsigned long int))EventArgsVirtualTableInstance->AncestorTable->IsSameTypeThanTypeID;
        EventArgsVirtualTableInstance->IsKindOfTypeID = (bool (*)(EventArgs* this, unsigned long int))EventArgsVirtualTableInstance->AncestorTable->IsKindOfTypeID;
        EventArgsVirtualTableInstance->IsSameTypeThan = (bool (*)(EventArgs* this, Class*))EventArgsVirtualTableInstance->AncestorTable->IsSameTypeThan;
        EventArgsVirtualTableInstance->IsKindOf = (bool (*)(EventArgs* this, Class*))EventArgsVirtualTableInstance->AncestorTable->IsKindOf;
    }
    EventArgsVirtualTableInstance->Interface->Constructor(this, pArgsCount, pParameters);
    EventArgsVirtualTableInstance->ReferenceCount++;
    return EventArgsVirtualTableInstance;
}

void EventArgsConstructor(EventArgs* this, unsigned long int pArgsCount, va_list* pParameters)
{

}

void EventArgsDestructor(EventArgs* this)
{

}

EventArgs* EventArgsClone(EventArgs* this)
{
    EventArgs* vClone = 0;
    vClone = new((void*(*)(unsigned long int, va_list*))this->VirtualTable->new, 0);
    return vClone;
}

